package com.redare.dev.smart.generator.workbench.controller;

import com.redare.dev.smart.generator.sdk.OnlFormFieldSdk;
import com.redare.dev.smart.generator.sdk.pojo.OnlFormField;
import com.redare.dev.smart.generator.sdk.pojo.form.OnlFormFieldForm;
import com.redare.devframework.common.pojo.CommonResult;
import com.redare.devframework.common.pojo.Page;
import com.redare.devframework.webplatform.workbench.conf.annotations.WebFun;
import com.redare.devframework.webplatform.workbench.controller.component.BaseWebController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

/**
 * @date 2021-08-28 23:03:12
 * Created by yangqiangyu
 */


@RequestMapping(value = "/api/_generator_api/onlFormField")
@Controller
public class OnlFormFieldController extends BaseWebController {

    @Autowired
    OnlFormFieldSdk onlFormFieldSdk;


    @ResponseBody
    @RequestMapping(value = "/add", method = RequestMethod.POST)
    @WebFun(classifyName = "管理", id = "OnlFormFieldAdd", name = "添加")
    public CommonResult<Boolean> addOnlFormField(
            @RequestBody OnlFormFieldForm.Add form
    ) {
        return onlFormFieldSdk.addOnlFormField(form);
    }

    @ResponseBody
    @RequestMapping(value = "/edit", method = RequestMethod.POST)
    @WebFun(classifyName = "管理", id = "OnlFormFieldEdit", name = "编辑")
    public CommonResult<Boolean> editOnlFormField(
            @RequestBody OnlFormFieldForm.Edit form
    ) {
        return onlFormFieldSdk.editOnlFormField(form);
    }

    @ResponseBody
    @RequestMapping(value = "/delete", method = RequestMethod.POST)
    @WebFun(classifyName = "管理", id = "OnlFormFieldDel", name = "删除")
    public CommonResult<Boolean> deleteOnlFormField(
            @RequestBody OnlFormFieldForm.Del form
    ) {
        return onlFormFieldSdk.deleteOnlFormField(form);
    }

    @ResponseBody
    @RequestMapping(value = "/info", method = RequestMethod.POST)
    public CommonResult<OnlFormField> getOnlFormField(
            @RequestBody OnlFormFieldForm.Get form
    ) {
        return onlFormFieldSdk.getOnlFormField(form);
    }


    @ResponseBody
    @RequestMapping(value = "/page", method = RequestMethod.POST)
    public CommonResult<Page<OnlFormField>> findOnlFormFieldPage(
            @RequestBody OnlFormFieldForm.Search form,
            @RequestParam(value = "curPage", required = false, defaultValue = "1") int curPage,
            @RequestParam(value = "pageSize", required = false, defaultValue = "10") int pageSize
    ) {
        return onlFormFieldSdk.findOnlFormFieldPage(form, curPage, pageSize);
    }


}